{%- macro comment_list(comments,children,pid) %}
    <ul class="{% if children %}comment-children{% else %}comments{% endif %}" id="comment-item-0">
        {% for item in comments %}
            <li class="comment-item" id="comment-item-{{ strval(item.getId()) }}">
                <div class="comment-self clearfix" id="comment-item-{{ item.getId() }}">
                    <div class="comment-header clearfix">
                        {% if item.anonymous is defined AND item.anonymous %}
                            <div class="comment-avatar">
                                <a href="#">
                                    <img alt="匿名用户" src="/modules/user/face/avatar{{ rand(1,5) }}.png">
                                </a>
                            </div>

                            <p class="comment-user-info">
                                <a href="#" class="comment-user-name">匿名用户</a>
                                <span title="{{ timeTran(item.created) }}" class="comment-time">{{ timeTran(item.created) }}</span>
                                <span class="comment-user-description">这个人很懒，什么都没有留下</span>
                            </p>
                        {% else %}
                        <div class="comment-avatar">
                            <a href="{{ url(['for':'user','id':item.uid]) }}">
                                <img alt="角落" src="{% if item.user.face %}{{ item.user.face }}{% else %}https://avatar.duoshuo.com/avatar-50/214/226670.jpg{% endif %}">
                            </a>
                        </div>

                        <p class="comment-user-info">
                            <a href="{{ url(['for':'user','id':item.uid]) }}" class="comment-user-name">角落</a>
                            <span title="{{ timeTran(item.created) }}" class="comment-time">{{ timeTran(item.created) }}</span>
                            <span class="comment-user-description">这个人很懒，什么都没有留下</span>
                        </p>
                        {% endif %}
                    </div>
                    <div class="comment-body clearfix">
                        <div class="comment-content">{{ item.body }}</div>
                        <div class="comment-footer comment-action-wrapper">
                            <div class="comment-action comment-action-left">
                                <a class="comment-dp" href="{{ url(['for':'commentSubmit'],['nid':item.nid,'pid':strval(item.getId())]) }}">
                                    <i class="fa fa-edit" aria-hidden="true"></i>我要点评
                                </a>
                            </div>
                            <div class="comment-action comment-action-right">
                                <a class="comment-report" data-toggle="tooltip" data-placement="top" title="举报" href="{{ url(['for':'commentReport','id':item.getId()]) }}"><i class="fa fa-flag" aria-hidden="true"></i></a>
                                <a class="comment-love" data-toggle="tooltip" data-placement="top" title="赞一下" href="{{ url(['for':'commentLove','id':item.getId()]) }}"><i class="fa fa-thumbs-up" aria-hidden="true"></i><span>{{ item.love }}</span></a>
                            </div>
                        </div>
                    </div>
                </div>
                {% set children = commentList(item.nid,item.getId()) %} {% if children.items %}{{ comment_list(children,true,item.getId()) }}{% endif %}
            </li>
        {% endfor %}
    </ul>
{%- endmacro %}

<div class="comment-list">
    {% if data %}
        {% if data.items is defined %}
            {{ comment_list(data.items,false,0) }}
        {% else %}
            {{ comment_list(data,false,0) }}
        {% endif %}
    {% else %}
        <ul class="comments">
            <p class="no-comment">{{ noComment }}</p>
        </ul>
    {% endif %}
</div>